package com.zb.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.entity.ZjWorkEngineerSign;
import com.zb.mapper.ZjWorkEngineerSignMapper;
import com.zb.service.ZjWorkEngineerSignService;
import com.zb.vo.OrderSlaSelectVo;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 工单工程师签到表，数据一对一 服务实现类
 * </p>
 *
 * @author WEN
 * @since 2024-03-19
 */
@Service
public class ZjWorkEngineerSignServiceImpl extends ServiceImpl<ZjWorkEngineerSignMapper, ZjWorkEngineerSign> implements ZjWorkEngineerSignService {

    // 根据工单ID & 服务工程师ID获取签到信息
    @Override
    public Date getSignTimeByWorkIdAndNetworkEmpId(Long workId, Long networkEmpId) {
        QueryWrapper<ZjWorkEngineerSign> wrapper = new QueryWrapper<>();
        wrapper.select("sign_in_time")
                .eq("work_id", workId).eq("network_emp_id", networkEmpId)
                .last("LIMIT 1");
        ZjWorkEngineerSign engineerSign = this.getOne(wrapper);
        return null == engineerSign? null : engineerSign.getSignInTime();
    }

    // 根据派单工程师ID查询工程师签到
    @Override
    public ZjWorkEngineerSign getByWorkDispatchEngineerId(Long workDispatchEngineerId) {
        QueryWrapper<ZjWorkEngineerSign> wrapper = new QueryWrapper<>();
        wrapper.select("id", "work_id", "network_id", "network_emp_id", "work_dispatch_engineer_id", "sign_type", "sign_in_time", "sign_in_distance",
                        "sign_in_province", "sign_in_city", "sign_in_area", "sign_in_town", "sign_in_address")
                .eq("work_dispatch_engineer_id", workDispatchEngineerId);
        return this.getOne(wrapper);
    }
}
